<template>
  <div class="wraps">
    <div class="header">
      <div class="header_title">
        <div class="header_left"><a href=""><img src="../../../assets/wechat/images/jiantou.png"></a></div>
        <div class="header_title2"><img src="../../../assets/wechat/images/logo.png"></div>
      </div>
    </div>
    <div class="ba_100 dw_47" style="height: 100%;">
      <div class="banner">
        <img src="../../../assets/wechat/images/banner.png">
      </div>
      <div class="fabu1 inqur">
        <div class="w92 xiahu">
          <div class="fabu_title">
            车牌号
          </div>
          <input
            id="carrierNumber"
            v-model="carrierNumber"
            type="text"
            name="carrierNumber"
            class="duan_input"
            placeholder="请输入车牌号"
          >
        </div>
      </div>
      <div class="fabu1 inqur">
        <div class="w92 xiahu">
          <div class="fabu_title">
            手机号
          </div>
          <input
            id="driverPhone"
            v-model="driverPhone"
            type="text"
            name="driverPhone"
            class="duan_input"
            placeholder="请输入手机号"
          >
        </div>
      </div>
      <div class="order_ti w92">
        <img src="../../../assets/wechat/images/tishi.png">查看当前订单信息
      </div>
      <a @click="list()"><input type="submit" value="查询" class="sub w92"></a>
    </div>
  </div>
</template>
<script>
import axios from 'axios'

export default {
  data() {
    return {
      carrierNumber: '',
      driverPhone: ''
    }
  },
  methods: {
    list() {
      const that = this
      if (that.carrierNumber === '' && that.driverPhone === '') {
        that.$message('车牌号和手机号二者必须填写一个')
        return
      }
      axios({
        method: 'get',
        url: 'http://localhost:9001/vehicleAppointment?carrierNumber=' + that.carrierNumber + '&driverPhone=' + that.driverPhone
      }).then(function(result) {
        if (result.status === 200 && result.data.status === 0 && result.data.data.total > 0) {
          that.$router.push({
            path: '/wechat/order/list',
            query: { carrierNumber: that.carrierNumber, driverPhone: that.driverPhone }
          })
        } else {
          that.$message('没有订单信息')
          return
        }
      }).catch(function(error) {
        that.$message('系统错误')
        return
      })
    }
  }
}
</script>
<style lang="scss" type="text/scss" scoped>
  /* 引入外部css */
  @import "../../../styles/wechat/public.css";
</style>
